From: kaf24@firebug.cl.cam.ac.uk Date: Thu, 29 Sep 2005 14:49:54 +0000 (+0100) Subject: Define new notify_remote_via_irq() interface which is a X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16769^2~10 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=756af00b03fb13c918afa6c57ed368bd4333a5a7;p=xen.git Define new notify_remote_via_irq() interface which is a safe version for drivers to use that is aware of save/restore. Post-restore notifications are silently dropped, in the expectation that xenbus will eventually get round to telling the driver it needs to reconnect. Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c index 5e5ccc8d19..483d3ea29d 100644 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c @@ -133,7 +133,7 @@ static inline void __send_IPI_one(unsigned int cpu, int vector) { int evtchn = per_cpu(ipi_to_evtchn, cpu)[vector]; BUG_ON(evtchn < 0); - notify_via_evtchn(evtchn); + notify_remote_via_evtchn(evtchn); } void __send_IPI_shortcut(unsigned int shortcut, int vector) diff --git a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c index 32294c7bcd..cef53c81cc 100644 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c @@ -622,6 +622,14 @@ void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) synch_set_bit(evtchn, &s->evtchn_pending[0]); } +void notify_remote_via_irq(int irq) +{ + int evtchn = irq_to_evtchn[irq]; + + if (VALID_EVTCHN(evtchn)) + notify_remote_via_evtchn(evtchn); +} + void irq_resume(void) { evtchn_op_t op; diff --git a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c index 807f0fd9b4..faa65e712e 100644 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c @@ -33,7 +33,7 @@ static inline void __send_IPI_one(unsigned int cpu, int vector) { int evtchn = per_cpu(ipi_to_evtchn, cpu)[vector]; BUG_ON(evtchn < 0); - notify_via_evtchn(evtchn); + notify_remote_via_evtchn(evtchn); } void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest) diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c index 134c8d06c3..c769342255 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c @@ -481,7 +481,7 @@ static void make_response(blkif_t *blkif, unsigned long id, spin_unlock_irqrestore(&blkif->blk_ring_lock, flags); /* Kick the relevant domain. */ - notify_via_evtchn(blkif->evtchn); + notify_remote_via_irq(blkif->irq); } void blkif_deschedule(blkif_t *blkif) diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index 209cd6b101..eec15e3864 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -84,7 +84,7 @@ static inline void ADD_ID_TO_FREELIST( static inline void flush_requests(struct blkfront_info *info) { RING_PUSH_REQUESTS(&info->ring); - notify_via_evtchn(info->evtchn); + notify_remote_via_irq(info->irq); } static void kick_pending_request_queues(struct blkfront_info *info) diff --git a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c index 7339ce805e..748dcdd2c0 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c @@ -842,7 +842,7 @@ static void make_response(blkif_t *blkif, unsigned long id, spin_unlock_irqrestore(&blkif->blk_ring_lock, flags); /* Kick the relevant domain. */ - notify_via_evtchn(blkif->evtchn); + notify_remote_via_irq(blkif->irq); } static struct miscdevice blktap_miscdev = { diff --git a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c index 2402a76ea4..c74b045db2 100644 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c @@ -46,7 +46,8 @@ static inline struct ring_head *inring(void) /* don't block - write as much as possible and return */ -static int __xencons_ring_send(struct ring_head *ring, const char *data, unsigned len) +static int __xencons_ring_send( + struct ring_head *ring, const char *data, unsigned len) { int copied = 0; @@ -63,13 +64,9 @@ static int __xencons_ring_send(struct ring_head *ring, const char *data, unsigne int xencons_ring_send(const char *data, unsigned len) { - struct ring_head *out = outring(); - int sent = 0; - - sent = __xencons_ring_send(out, data, len); - notify_via_evtchn(xen_start_info->console_evtchn); + int sent = __xencons_ring_send(outring(), data, len); + notify_remote_via_irq(xencons_irq); return sent; - } diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c index 3170303e8b..a4f9c447d2 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c @@ -42,7 +42,7 @@ static multicall_entry_t rx_mcl[NETIF_RX_RING_SIZE*2+1]; static mmu_update_t rx_mmu[NETIF_RX_RING_SIZE]; static gnttab_transfer_t grant_rx_op[MAX_PENDING_REQS]; -static unsigned char rx_notify[NR_EVENT_CHANNELS]; +static unsigned char rx_notify[NR_IRQS]; /* Don't currently gate addition of an interface to the tx scheduling list. */ #define tx_work_exists(_if) (1) @@ -209,7 +209,7 @@ static void net_rx_action(unsigned long unused) { netif_t *netif = NULL; s8 status; - u16 size, id, evtchn; + u16 size, id, irq; multicall_entry_t *mcl; mmu_update_t *mmu; gnttab_transfer_t *gop; @@ -320,16 +320,16 @@ static void net_rx_action(unsigned long unused) gop->status, netif->domid); /* XXX SMH: should free 'old_mfn' here */ status = NETIF_RSP_ERROR; - } - evtchn = netif->evtchn; + } + irq = netif->irq; id = netif->rx->ring[ MASK_NETIF_RX_IDX(netif->rx_resp_prod)].req.id; if (make_rx_response(netif, id, status, (unsigned long)skb->data & ~PAGE_MASK, size, skb->proto_csum_valid) && - (rx_notify[evtchn] == 0)) { - rx_notify[evtchn] = 1; - notify_list[notify_nr++] = evtchn; + (rx_notify[irq] == 0)) { + rx_notify[irq] = 1; + notify_list[notify_nr++] = irq; } netif_put(netif); @@ -339,9 +339,9 @@ static void net_rx_action(unsigned long unused) } while (notify_nr != 0) { - evtchn = notify_list[--notify_nr]; - rx_notify[evtchn] = 0; - notify_via_evtchn(evtchn); + irq = notify_list[--notify_nr]; + rx_notify[irq] = 0; + notify_remote_via_irq(irq); } /* More work to do? */ @@ -717,7 +717,7 @@ static void make_tx_response(netif_t *netif, mb(); /* Update producer before checking event threshold. */ if (i == netif->tx->event) - notify_via_evtchn(netif->evtchn); + notify_remote_via_irq(netif->irq); } static int make_rx_response(netif_t *netif, diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index abb4524dca..132f0026f4 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -457,7 +457,7 @@ static int network_start_xmit(struct sk_buff *skb, struct net_device *dev) /* Only notify Xen if we really have to. */ mb(); if (np->tx->TX_TEST_IDX == i) - notify_via_evtchn(np->evtchn); + notify_remote_via_irq(np->irq); return 0; @@ -776,7 +776,7 @@ static void network_connect(struct net_device *dev) */ np->backend_state = BEST_CONNECTED; wmb(); - notify_via_evtchn(np->evtchn); + notify_remote_via_irq(np->irq); network_tx_buf_gc(dev); if (np->user_state == UST_OPEN) diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c index 17726f8989..0fe22a43f2 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c @@ -308,7 +308,7 @@ _packet_write(struct packet *pak, rc = offset; DPRINTK("Notifying frontend via event channel %d\n", tpmif->evtchn); - notify_via_evtchn(tpmif->evtchn); + notify_remote_via_irq(tpmif->irq); return rc; } diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c index 516aae330d..dadb866568 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -682,7 +682,7 @@ tpm_xmit(struct tpm_private *tp, DPRINTK("Notifying backend via event channel %d\n", tp->evtchn); - notify_via_evtchn(tp->evtchn); + notify_remote_via_irq(tp->irq); spin_unlock_irq(&tp->tx_lock); return offset; diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c index 972236d285..7c9d8f6ec2 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c @@ -147,7 +147,7 @@ int xb_write(const void *data, unsigned len) data += avail; len -= avail; update_output_chunk(out, avail); - notify_via_evtchn(xen_start_info->store_evtchn); + notify_remote_via_irq(xenbus_irq); } while (len != 0); return 0; @@ -192,7 +192,7 @@ int xb_read(void *data, unsigned len) pr_debug("Finished read of %i bytes (%i to go)\n", avail, len); /* If it was full, tell them we've taken some. */ if (was_full) - notify_via_evtchn(xen_start_info->store_evtchn); + notify_remote_via_irq(xenbus_irq); } /* If we left something, wake watch thread to deal with it. */ diff --git a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h index 360388fec6..d2f5279be8 100644 --- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h +++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h @@ -75,6 +75,12 @@ extern int bind_evtchn_to_irqhandler( void *dev_id); extern void unbind_evtchn_from_irqhandler(unsigned int irq, void *dev_id); +/* + * Unlike notify_remote_via_evtchn(), this is safe to use across + * save/restore. Notifications on a broken connection are silently dropped. + */ +void notify_remote_via_irq(int irq); + extern void irq_resume(void); /* Entry point for notifications into Linux subsystems. */ @@ -115,12 +121,12 @@ static inline void clear_evtchn(int port) synch_clear_bit(port, &s->evtchn_pending[0]); } -static inline int notify_via_evtchn(int port) +static inline void notify_remote_via_evtchn(int port) { evtchn_op_t op; op.cmd = EVTCHNOP_send; op.u.send.local_port = port; - return HYPERVISOR_event_channel_op(&op); + (void)HYPERVISOR_event_channel_op(&op); } /*